package com.ifpe.ifmoodledroid.adapters;

import java.util.List;

import com.ifpe.ifmoodledroid.model.Curso;

import android.R;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

public class CursoAdapter extends BaseAdapter {

	private List<Curso> cursos;
	private Context contexto;

	public CursoAdapter(Context contexto, List<Curso> cursos) {
		this.contexto = contexto;
		this.cursos = cursos;
	}

	public int getCount() {
		// TODO Auto-generated method stub
		return 1;
	}

	public Object getItem(int posicao) {
		// TODO Auto-generated method stub
		return cursos.get(posicao);
	}

	public long getItemId(int pos) {
		// TODO Auto-generated method stub
		return pos;
	}

	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		Curso curso = cursos.get(position);
		ViewHolder holder;

		if (convertView == null) {
			convertView = LayoutInflater.from(contexto).inflate(
					com.ifpe.ifmoodledroid.R.layout.tela_cursos, null);
			holder = new ViewHolder();

			holder.nomeCurso = (TextView) convertView
					.findViewById(com.ifpe.ifmoodledroid.R.id.nomeCurso);
			
			convertView.setTag(holder);
		}else{
			holder = (ViewHolder) convertView.getTag();
		}
		holder.nomeCurso.setText(String.valueOf(curso.getNome()));
		
		return convertView;
	}

	static class ViewHolder {
		TextView nomeCurso;
	}
}
